<!--
 * @Description: htm
 * @Author: charles
 * @Date: 2021-06-18 11:57:10
 * @LastEditors: charles
 * @LastEditTime: 2021-06-18 15:06:15
-->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>threejs</title>
  <style>
    body {
      margin: 0;
    }
  </style>
  <script src="https://cdn.bootcdn.net/ajax/libs/three.js/r128/three.min.js"></script>
</head>
<body>
  <div id="container" style=" margin: auto;"></div>
  <script>
    	let container = document.getElementById('container');
      // 1. 创建场景
      const scene = new THREE.Scene();
      // 2. 创建模型
      // 2.1 创建网格模型
      const geometry = new THREE.BoxGeometry(10,200,200);
	    const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
	    const cube = new THREE.Mesh( geometry, material );
	    scene.add( cube );
	    // 点光源
	    var point = new THREE.PointLight(0xffffff);
	    point.position.set(400, 200, 300); //点光源位置
	    scene.add(point);


     //18896827921
      // 3. 创建摄像机
      
      const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
      camera.position.z = 5;



       // 4. 创建渲染器
      const renderer = new THREE.WebGLRenderer();
      renderer.setSize( window.innerWidth, window.innerHeight );
      container.appendChild( renderer.domElement );

      // 5. 执行渲染
      const animate = function () {
      requestAnimationFrame( animate );
	      cube.rotation.x += 0.01;
	      cube.rotation.y += 0.01;
	      renderer.render( scene, camera );
	    };

	    animate();
  </script>
</body>
</html>